package me.lovatcat.springboot.demo.vo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 使用内部类定义属性，可以实现属性相同，值不同的配置需求
 * @author acat on 2017-01-12 14:47
 */
@Component
@ConfigurationProperties(prefix = "computer", locations = {"classpath:config/computer.yml"})
public class Computer {

    private ComputerInfo lenovo;

    private ComputerInfo apple;

    public ComputerInfo getLenovo() {
        return lenovo;
    }

    public void setLenovo(ComputerInfo lenovo) {
        this.lenovo = lenovo;
    }

    public ComputerInfo getApple() {
        return apple;
    }

    public void setApple(ComputerInfo apple) {
        this.apple = apple;
    }

    public static class ComputerInfo{
        private String brand;

        private String price;

        private String color;

        public String getBrand() {
            return brand;
        }

        public void setBrand(String brand) {
            this.brand = brand;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }

        @Override
        public String toString() {
            return "ComputerInfo{" +
                    "brand='" + brand + '\'' +
                    ", price='" + price + '\'' +
                    ", color='" + color + '\'' +
                    '}';
        }
    }

    @Override
    public String toString() {
        return "Computer{" +
                "lenovo=" + lenovo +
                ", apple=" + apple +
                '}';
    }
}
